<?php
include_once 'config.php';
$result = array();
$i=0;
if (($handle = opendir('model'))) {
    /* This is the correct way to loop over the directory. */
    while (false !== ($entry = readdir($handle))) {
        if ($entry == "." || $entry == ".." || end(explode('.', $entry)) != "model") continue;
        $result[$i]["link"] = "http://".$_SERVER["HTTP_HOST"]."/wekaws/model/".$entry;
        $result[$i]["model_name"] = $entry;
        $result[$i]["date"] = date("d-M-Y",filectime("model/".$filename));
        $result[$i]["time"] = date("H:i:s",filectime("model/".$filename));
        $result[$i]["attribute"] = exec($program."attribute model/".$entry);
        $i++;
    }
    closedir($handle);
}

echo json_encode($result);
?>
